package com.lxhll.personnel.controller.transfer;


import com.aliyun.oss.OSS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lxhll.personnel.core.ResponseData;
import com.lxhll.personnel.entity.DepartmentTransfer;
import com.lxhll.personnel.entity.Employee;
import com.lxhll.personnel.service.DepartmentService;
import com.lxhll.personnel.service.DepartmentTransferService;
import com.lxhll.personnel.service.EmployeeService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * (DepartmentTransfer)表控制层
 *处理员工部门调动，因为只对一个部门id做改动，所以会更简单！
 仅提供部门调动历史信息查询，调动详细信息，更改已有调动信息等
 * @author liangyi
 * @since 2021-07-22 14:51:48
 */
@RestController
@RequestMapping("/department_transfer")
public class DepartmentTransferController {
    /**
     * 部门调动
     */
    @Autowired
    private DepartmentTransferService transferService;


    /**
     * 查看以调动员工部门调动信息
     */
    @PostMapping("/list")
    public ResponseData list(@RequestBody Map<String,Object> params){
        IPage<Map<String,Object>> page=transferService.queryTransfers(params);
        return ResponseData.ok(page);
    }
    
    @GetMapping("/info/{id}")
    public ResponseData info(@PathVariable Integer id){
        return ResponseData.ok(transferService.getTransferById(id));
    }

    @PostMapping("/save")
    public ResponseData save(@RequestBody DepartmentTransfer transfer){
        //获取部门调转信息
        //设置调转时间,插入调动信息
        if(transferService.saveTransfer(transfer)){
             return ResponseData.ok();
        }
        return ResponseData.error();
    }
}
